﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Core.Logging
{
    /// <summary>
    /// Represents an object that can be logged to the database
    /// </summary>
    public interface ILoggable
    {
        /// <summary>
        /// The ID of the object to log
        /// </summary>
        Guid? LogObjectID { get; }
        /// <summary>
        /// The name of the object to log
        /// </summary>
        string LogObjectName { get; }
        /// <summary>
        /// The type of the object's log entry
        /// </summary>
        LogEntryType LogType { get; }
    }

    /// <summary>
    /// Represents a generic loggable object
    /// Use when you don't have something more specific to log
    /// </summary>
    public class LoggableObject : ILoggable
    {
        string _name;
        LogEntryType _type;

        public LoggableObject() 
            : this(string.Empty, LogEntryType.Node)
        {
        }

        public LoggableObject(LogEntryType type)
            : this(string.Empty, type)
        {
        }

        public LoggableObject(string name, LogEntryType type)
        {
            _name = name;
            _type = type;
        }

        public LoggableObject(ILoggable log)
            : this(log.LogObjectName, log.LogType)
        {
        }

        Guid? ILoggable.LogObjectID 
        {
            get
            {
                return null;
            }
        }
        string ILoggable.LogObjectName 
        {
            get
            {
                return _name;
            }
        }
        LogEntryType ILoggable.LogType 
        {
            get
            {
                return _type;
            }
        }
    }
}
